package com.xian.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xian.common.annotation.Log;
import com.xian.common.core.controller.BaseController;
import com.xian.common.core.domain.AjaxResult;
import com.xian.common.enums.BusinessType;
import com.xian.manage.domain.OperaTicket;
import com.xian.manage.service.IOperaTicketService;
import com.xian.common.utils.poi.ExcelUtil;
import com.xian.common.core.page.TableDataInfo;

/**
 * 演出票务管理Controller
 * 
 * @author Hanys
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/manage/ticket")
public class OperaTicketController extends BaseController
{
    @Autowired
    private IOperaTicketService operaTicketService;

    /**
     * 查询演出票务管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:ticket:list')")
    @GetMapping("/list")
    public TableDataInfo list(OperaTicket operaTicket)
    {
        startPage();
        List<OperaTicket> list = operaTicketService.selectOperaTicketList(operaTicket);
        return getDataTable(list);
    }

    /**
     * 导出演出票务管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:ticket:export')")
    @Log(title = "演出票务管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OperaTicket operaTicket)
    {
        List<OperaTicket> list = operaTicketService.selectOperaTicketList(operaTicket);
        ExcelUtil<OperaTicket> util = new ExcelUtil<OperaTicket>(OperaTicket.class);
        util.exportExcel(response, list, "演出票务管理数据");
    }

    /**
     * 获取演出票务管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:ticket:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(operaTicketService.selectOperaTicketById(id));
    }

    /**
     * 新增演出票务管理
     */
    @PreAuthorize("@ss.hasPermi('manage:ticket:add')")
    @Log(title = "演出票务管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperaTicket operaTicket)
    {
        return toAjax(operaTicketService.insertOperaTicket(operaTicket));
    }

    /**
     * 修改演出票务管理
     */
    @PreAuthorize("@ss.hasPermi('manage:ticket:edit')")
    @Log(title = "演出票务管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperaTicket operaTicket)
    {
        return toAjax(operaTicketService.updateOperaTicket(operaTicket));
    }

    /**
     * 删除演出票务管理
     */
    @PreAuthorize("@ss.hasPermi('manage:ticket:remove')")
    @Log(title = "演出票务管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(operaTicketService.deleteOperaTicketByIds(ids));
    }
}
